package com.bobbyjjw.testTaobao;

import com.bobbyjjw.client.CommonClient;
import com.bobbyjjw.session.GetAuthCode;
import com.bobbyjjw.session.GetSessionKey;
import com.taobao.api.TaobaoJsonRestClient;
import com.taobao.api.model.ProductAddRequest;
import com.taobao.api.model.ProductAddResponse;

/**
 * 卖家登录后，发布新的产品
 * 
 * @author Bobby.Jin
 *
 */

public class TaobaoProductAdd {
	public static void main(String args[]) throws Exception {
		TaobaoJsonRestClient client = CommonClient.getInstance();
		ProductAddRequest request = new ProductAddRequest();
		String authCode = GetAuthCode.getAuthCode();
		String sessionKey = GetSessionKey.getSessionKey(authCode);
		System.out.println(sessionKey);
		request.setCid("50008165");
		request.setOuterId("200612"); // 商家编码
		request.setProps("20000:30812;1632501:31578;21861:3683581"); // 关键属性
		request.setBinds("1637400:4606395;21862:31578"); // 非关键属性
		request.setCustomerProps("21861:自定义属性值"); // 自定义属性
		request.setSaleProps("1627207:28324"); // 销售属性
		request.setName("山寨E71"); // 产品名称
		request.setPrice("100"); // 产品价钱
		request.setDesc("测试添加产品"); // 产品描述
		ProductAddResponse response = client.productAdd(request, sessionKey);
		System.out.println(response.getBody());
	}
}